package com.monster.hellospringmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;


/**
 * description:
 *
 * @author Yuanml on 2020/12/16 21:20
 */
@Controller
public class HelloController {
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public ModelAndView hello(String name) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("name", name);
        modelAndView.setViewName("/WEB-INF/template/hello.jsp");
        return modelAndView;
    }

    @RequestMapping(value = "/hello2", method = RequestMethod.GET)
    public String hello2(Model model, String name) {
        model.addAttribute("name2", name);
        return "hello";
    }
}
